<?php
use \yii\helpers\Html;
use \yii\widgets\LinkPager;
use \yii\grid\GridView;
use \yii\grid\SerialColumn;
use \yii\grid\DataColumn;
use app\models\Post;
use app\models\Lookup;
$this->params['breadcrumbs']=array(
	'Manage Posts',
);

$deleteJS = <<<DEL
$('.container').on('click','.table a.delete',function() {
	if(confirm('Are you sure you want to delete this item?')) {
		return true;
	}
	return false;
});

DEL;
$this->registerJs($deleteJS);
?>
<?php
echo GridView::widget(array(
	'caption'=>'<h1>Manage Posts</h1>',
	'dataProvider'=>$provider,
	'columns' => array(
		array(
			'class' => SerialColumn::className(),
			'header' => '#'
		),
		array(
			'class' => DataColumn::className(),
			'attribute'=>'title',
			'header' => 'title',
			'content'=>function($data, $row) {
				return Html::a(Html::encode($data->title), $data->url);
			},
			'format'=>'html',
			'value'=>function($data, $row) {
				return Html::a(Html::encode($data->title), $data->url);
			}
		),
		array(
			'class' => DataColumn::className(),
			'attribute'=>'status',
			'content'=>function($data, $row) {
				return Lookup::item("PostStatus",$data->status);
			},
			'header'=>'status'
		),
		array(
			'class' => DataColumn::className(),
			'attribute'=>'create_time',
			'content'=>function($data, $row) {
				return date("Y/m/d", $data->create_time);
			},
			'header' => 'create_time',
		),
		array(
			'class' => DataColumn::className(),
			'content'=>function($data, $row) {
				$html = Html::a(NULL, array("update", "id"=>$data->id), array('class' => 'icon icon-edit'));
				$html .= ' | ';
				$html .= Html::a(NULL, array("delete", "id"=>$data->id), array('class'=>'delete icon icon-trash'));
				return $html;
			}
		),
	)
));




?>


